#include "../../../common/rabbitmq.hpp"
#include "../../../common/logger.hpp"
#include <gflags/gflags.h>

DEFINE_string(user,"root","rabbitmq 客户端访问的用户");
DEFINE_string(passwd,"123456","rabbitmq 客户端的密码");
DEFINE_string(host,"127.0.0.1:5672","rabbitmq服务器的ip和端口");

DEFINE_bool(run_mode,false,"程序的运行模式，false： 调试 true： 发布");
DEFINE_string(log_file,"","发布模式下，向文件中输出，如果是调试模式下，模式是stdout");
DEFINE_int32(log_level,0,"发布模式下，用于指定的日志输出等级");

void callback(const char* body,size_t sz) {
    std::string msg;
    msg.assign(body,sz);
    std::cout << msg << std::endl;
}

int main(int argc,char* argv[]) {
    google::ParseCommandLineFlags(&argc,&argv,true);
    init_logger(FLAGS_run_mode,FLAGS_log_file,FLAGS_log_level);

    MQClient client(FLAGS_user,FLAGS_passwd,FLAGS_host);

    client.declareComponents("test-exchange","test-queue");
    client.consume("test-queue",callback);

    std::this_thread::sleep_for(std::chrono::seconds(60));

    return 0;
}
